package _220329;

import java.util.Scanner;

/**
 * @author ShadowLim
 * @create 2022-03-29-8:45
 */

// https://blog.csdn.net/qq_39304630/article/details/118444551
public class 排列数 {
//    static int mod = 123456;
//    static int N = 500;
//    static int[][] dp;
//    static int n, k;
//
//    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//        n = scanner.nextInt();
//        k = scanner.nextInt();
//        dp = new int[N + 5][N + 5];
//        dp[1][0] = 1;
//        for (int i = 2; i <= n; i++) {
//            dp[i][0] = 2;
//            for (int j = 0; j <= i - 2; j++) {
//                dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * (j + 1) % mod) % mod;
//                dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j] * 2 % mod) % mod;
//                dp[i + 1][j + 2] = (dp[i + 1][j + 2] + dp[i][j] * (i - j - 2) % mod) % mod;
//            }
//        }
//        System.out.println(dp[n][k - 1]);
//    }
    static int MOD = 123456;
    static int N = 1005;
    static int n, k;
    static int[] a = new int[N];

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        k = scanner.nextInt();
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            a[i] = i;
        }
        f(a, 1);
        int count = 0;
        for (int i = 2; i <= n - 1; i++) {
            if (a[i] > a[i - 1] && a[i] > a[i + 1]
                || a[i] < a[i - 1] && a[i] < a[i + 1]) {
                count++;
            }
        }
        if (count + 1 == n) {
            ans++;
        }
        System.out.println(ans % MOD);
    }

    private static void f(int[] a, int cnt) {
        if (cnt == n) {
            return;
        }
        for (int i = 1; i <= n; i++) {
            int t = a[i];
            a[i] = a[cnt];
            a[cnt] = t;

            f(a, cnt + 1);

            t = a[cnt];
            a[cnt] = a[i];
            a[i] = t;
        }
    }
}
